var sample = require('../core/samples')
var dbselect = require('../core/assertion')
var resultco = require('../core/reports/reportModel')
var map = new Map()

var interfacemodel = {
    url:'http://10.100.2.36:8086/api/operation/authenticate/account',
    repData:{
        login:"admin",
        password:"wujun27",
        type : "account"
    },
    headers:{
        headers: {
            'content-type': "application/json; charset=utf-8",
        },
        method: 'post',
        timeout:10000,
    }
}

var cb = function(data,callback){
    dbselect.dbassert.query("select * from yxx_dictionary",null,function (err,vals,fields) {
        console.log("ccccc",Array.from(vals))
        console.log(data.data["id_token"]);
        var result = new resultco();
        result.setName("ccc")
        result.setResponseCode(data.status)
        map.set(result.getName(),result)
    callback("2222222222")}
)

}
var resultreduce = function(data){
    console.log(data)
    dbselect.dbassert.pool.end(function () {
        console.log("mysql end")
    })
    console.log(map)
}
/*
sample.httpResquest(interfacemodel.url,interfacemodel.repData,interfacemodel.headers)
    .then(function (data) {
        dbselect.dbassert("select * from yxx_dictionary",null,function (err,vals,fields) {
                console.log(Array.from(vals))
            console.log(data.data["id_token"]);
    })
    .catch()
*/

    sample.httpResquest(interfacemodel.url,interfacemodel.repData,interfacemodel.headers)
        .then(data=>cb(data,resultreduce))
                .catch()
